package br.edu.infnet.avaliacao.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "bloco", catalog = "avaliacao")
public class Bloco implements java.io.Serializable {

	private static final long serialVersionUID = -7974057534080305510L;
	private Integer id;
	private Formacao formacao;
	private String nome;
	private Set<Disciplina> disciplinas = new HashSet<Disciplina>(0);

	public Bloco() {
	}

	public Bloco(Formacao formacao) {
		this.formacao = formacao;
	}

	public Bloco(Formacao formacao, String nome, Set<Disciplina> disciplinas) {
		this.formacao = formacao;
		this.nome = nome;
		this.disciplinas = disciplinas;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "formacao_id", nullable = false)
	public Formacao getFormacao() {
		return this.formacao;
	}

	public void setFormacao(Formacao formacao) {
		this.formacao = formacao;
	}

	@Column(name = "nome", length = 100)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "bloco")
	public Set<Disciplina> getDisciplinas() {
		return this.disciplinas;
	}

	public void setDisciplinas(Set<Disciplina> disciplinas) {
		this.disciplinas = disciplinas;
	}

}
